package six

import org.apache.spark.{SparkConf, SparkContext}

object ReduceByKeyTestScala {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("ReduceByKeyTest").setMaster("local")
    val sc = new SparkContext(conf)

    val list = List(("武当", 99), ("少林", 97), ("武当", 89), ("少林", 77))
    val mapRDD = sc.parallelize(list)

    //val resultRDD = mapRDD.reduceByKey((x, y) => x + y)
    val resultRDD = mapRDD.reduceByKey(_+_)
    resultRDD.foreach(tuple => println("门派: " + tuple._1 + "->" + tuple._2))
  }
}
